#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>

#include "debug.h"
#include "os_api.h"

	
#define _TASK_STACK_SIZE     1024*3
static void* _task_stack = NULL;
static OSTaskRef _task_ref = NULL;


#define PI 3.14159265

static void _task(void *ptr)
{
	double x, ret, val;

    x = 45.0;
    val = PI / 180;
    ret = sin(x*val);
    LOG_PRINTF("math_test: %lf sin is %lf", x, ret);
    
    x = 60.0;
    val = PI / 180;
    ret = cos(x*val);
    LOG_PRINTF("math_test: %lf cos is %lf", x, ret);

    x = 1.0;
    val = 180.0 / PI;
    ret = atan (x) * val;
    LOG_PRINTF("math_test: %lf atan is %lf", x, ret);			    
}


int main(void)
{
    int ret;

    _task_stack = malloc(_TASK_STACK_SIZE);
    ASSERT(_task_stack != NULL);
    
    ret = OSATaskCreate(&_task_ref, _task_stack, _TASK_STACK_SIZE, 120, "test-task", _task, NULL);
    ASSERT(ret == OS_SUCCESS);

    return 0;
}